<template lang="html">
  <div class="box">
    <div class="header">
        <el-form class="filterCondition demo-form-inline" ref="form"  :inline="true" label-width="80px">
            <el-input placeholder="输入市代名称" v-model="keyword" style="width: 420px;">
              <el-button slot="append" style="width: 120px;" @click="search()">搜索</el-button>
            </el-input>
            <el-form-item label="时间段" style="margin-bottom: 0;width: 520px;">
              <el-date-picker v-model="intervalTime" type="daterange" align="right" unlink-panels range-separator="-"
                start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;"
                value-format="yyyy-MM-dd HH:mm:ss" >
              </el-date-picker>
            </el-form-item>
        </el-form>
    </div>

    <div class="body">
        <el-table :data="tableData.list" style="width: 100%">
            <el-table-column  prop="supply_company"  align="center" label="市代名称" ></el-table-column>
            <el-table-column  prop="income"  align="center" label="售卡分佣" ></el-table-column>
            <el-table-column  prop="agent_company"  align="center" label="运营商名称" ></el-table-column>
            <el-table-column  prop="shop_name"  align="center" label="维修厂名称" ></el-table-column>
            <el-table-column  prop="user_name"  align="center" label="车主姓名" ></el-table-column>
            <el-table-column  prop="card_price"  align="center" label="购卡金额" ></el-table-column>
            <el-table-column  align="center" label="车型" >
                <template slot-scope="scope">
                  <el-popover placement="top" trigger="hover">
                    <p>{{scope.row.car_type}}-{{scope.row.car_brand}}</p>
                    <el-button type="primary" slot="reference" plain size="mini">{{scope.row.car_type}}</el-button>
                  </el-popover>
                </template>
            </el-table-column>
            <el-table-column  prop="create_time"  align="center" label="时间" ></el-table-column>
        </el-table>
    </div>
    <p  class="summary">{{tableData.total}}</p>
    <div class="page_box">
        <el-pagination class="page" layout="prev, pager, next"
          @current-change="switchPage" :current-page="currentPage" :page-count='tableData.rows' >
        </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      token: this.$store.state.user.token3,
      keyword:'',
      intervalTime:[],
      tableData:[],
      currentPage:1
    }
  },
  created(){
    this.search()
  },
  methods:{
    search(){
        this.currentPage = 1
        this.supplyCardIncList(this.currentPage)
    },
    supplyCardIncList(page=1){
      this.tableData = []
      this.$http3.supplyCardIncList({
        token: this.token,
        key: this.keyword,
        start_time: (this.intervalTime && this.intervalTime[0]) || '',
        end_time: (this.intervalTime && this.intervalTime[1]) || '',
        page: page
      }).
      then(res=>{
        this.tableData =
        res.data.code ==1?
        res.data.data: []
      })
    },
    switchPage(e){
      this.supplyCardIncList(e)
    }

  }
}
</script>

<style lang="css" scoped>
@import "../../../my-style/app.css";
/deep/ .el-input-group__append, .el-input-group__prepend{
  background-color: #3498E9;
  border: none;
  color: white;
}
/deep/ .table_box .preview-img{
  display:block;
  width: 100%;
  height: 30px;
}
.page_box{
  text-align: center;
}
</style>
